//package org.example.config;
//
//import org.springdoc.core.SwaggerUiConfigProperties;
////import org.springframework.cloud.gateway.route.Route;
////import org.springframework.cloud.gateway.route.RouteLocator;
//import org.springframework.cloud.gateway.route.Route;
//import org.springframework.cloud.gateway.route.RouteLocator;
//import org.springframework.stereotype.Component;
//import reactor.core.publisher.Flux;
//
//import java.util.Collection;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Component
//public class OpenApiConfig {
//
//    public OpenApiConfig(RouteLocator routeLocator, SwaggerUiConfigProperties swaggerUiConfig) {
//
////        List<Route> routes = routeLocator.getRoutes();
////        Flux<Route> routes = routeLocator.getRoutes();
//        Flux<Route> routes1 = routeLocator.getRoutes();
//        // 去重
//        Collection<Route> distinctRoutes = routes.toStream()
//                .collect(Collectors.toMap(Route::getUri, p -> p, (p, q) -> p)).values();
//
//        // 将服务名添加到下拉框
//        distinctRoutes.stream().filter(route -> route.getLocation().matches(".+-service")).forEach(route -> {
//            String serviceName = route.getLocation();
//            swaggerUiConfig.addGroup(serviceName);
//        }
//    }
